﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace HelloWPF.DataBinding.Convert
{
    public class DataConverter : IValueConverter
    {
        /// <summary>
        /// 表示从源到目标的转换
        /// </summary>
        /// <param name="value">数据源的值</param>
        /// <param name="targetType">目标属性的类型：可以根据目标类型处理不同的控件</param>
        /// <param name="parameter">转换参数</param>
        /// <param name="culture">国际化</param>
        /// <returns>将要给目标的值</returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if(int.Parse(value.ToString()) > 100)
            {
                return Brushes.Red;
            }
            return Brushes.Black;
        }

        /// <summary>
        /// 表示从目标到源转换
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType">目标属性的类型：可以根据目标类型处理不同的控件</param>
        /// <param name="parameter">转换参数</param>
        /// <param name="culture">国际化</param>
        /// <returns></returns>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
